package com.ocean.web.controller.product;

import com.ocean.common.core.controller.BaseController;
import com.ocean.common.core.domain.AjaxResult;
import com.ocean.common.core.page.TableDataInfo;
import com.ocean.nc.domain.ONcUnzip;
import com.ocean.nc.service.IONcUnzipService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 解压文件管理
 * @author msy
 * @date 2023/2/27
 */
@Controller
@RequestMapping("product/ncUnzip")
public class ONcUnzipController extends BaseController {

    private String prefix = "product/ncUnzip";

    @Autowired
    private IONcUnzipService ncUnzipService;

    @RequiresPermissions("product:ncUnzip:view")
    @GetMapping()
    public String view(){
        return prefix + "/ncUnzip";
    }

    @RequiresPermissions("product:ncUnzip:list")
    @PostMapping("list")
    @ResponseBody
    public TableDataInfo list(ONcUnzip ncUnzip){
        startPage();
        List<ONcUnzip> result = ncUnzipService.getNcUnzipList(ncUnzip);
        return getDataTable(result);
    }

    @RequiresPermissions("product:ncUnzip:remove")
    @PostMapping("remove")
    @ResponseBody
    public AjaxResult remove(String ids){
        try {
            ncUnzipService.deleteNcUnzipByIds(ids);
            return AjaxResult.success();
        }catch (Exception e){
            e.printStackTrace();
            return AjaxResult.error("删除失败");
        }
    }

    @RequiresPermissions("product:ncUnzip:removeCompeletly")
    @PostMapping("removeCompeletly")
    @ResponseBody
    public AjaxResult removeCompeletly(String ids){
        return toAjax(ncUnzipService.deleteCompeletly(ids));
    }
}
